import {
  createRouter,
  createWebHashHistory
} from 'vue-router'

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: '/',
      name: 'Home',
      component: () => import('../components/Home.vue'),
      redirect: '/logIn',
      children: [
        {
          path: '/index',
          name: 'AppIndex',
          component: () => import('../components/Appindex.vue'),
          meta: {
            requireAuth: true
          }
        },
        {
          path: '/admin',
          name: 'admin',
          component: () => import('../views/admin/admin.vue'),
          redirect:'/admin/userManage',
          children:[
            {
              path: '/admin/userManage',
              name: 'userManage',
              component: () => import('../views/admin/userManage.vue')
            },
            {
              path: '/admin/equipMsgManage',
              name: 'equipMsgManage',
              component: () => import('../views/admin/equipMsgManage.vue')
            },
            {
              path: '/admin/equipTypeManage',
              name: 'equipTypeManage',
              component: () => import('../views/admin/equipTypeManage.vue')
            },
            {
              path: '/admin/factoryManage',
              name: 'factoryManage',
              component: () => import('../views/admin/factoryManage.vue')
            },
            {
              path: '/admin/productMsgManage',
              name: 'productMsgManage',
              component: () => import('../views/admin/productMsgManage.vue')
            },
            {
              path: '/admin/productTypeManage',
              name: 'productTypeManage',
              component: () => import('../views/admin/productTypeManage.vue')
            },
            {
              path: '/admin/orderManage',
              name: 'orderManage',
              component: () => import('../views/admin/orderManage.vue')
            }

          ]

        },
        {
          path: '/factory',
          name: 'factory',
          component: () => import('../views/factory/factory.vue'),
          redirect:'/factory/equipManage',
          children:[
            {
              path: '/factory/equipManage',
              name: 'equipManage',
              component: () => import('../views/factory/equipManage.vue')
            },
            {
              path: '/factory/factoryOrderManage',
              name: 'factoryOrderManage',
              component: () => import('../views/factory/factoryOrderManage.vue')
            }
          ]
        },
        {
          path: '/customer',
          name: 'customer',
          component: () => import('../views/customer/customer.vue')
        }
      ]
    },
  {
    path: '/logIn',
    name: 'logIn',
    component: () => import('../views/logIn.vue')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('../views/register.vue')
  },

]
})

export default router;